package com.ssy.lingxi.member.merchant.entity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

/**
 * 会员等级配置
 * @author 万宁
 * @version 2.0.0
 * @date 2020-07-04
 */
@Entity
@Table(schema = "public", name = "ms_mc_member_level_config", indexes = {@Index(name = "ms_mc_member_level_config_member_id_idx", columnList = "memberId"), @Index(name = "ms_mc_member_level_config_role_id_idx", columnList = "roleId"), @Index(name = "ms_mc_member_level_config_sub_role_id_idx", columnList = "subRoleId"), @Index(name = "ms_mc_member_level_config_level_idx", columnList = "level"), @Index(name = "ms_mc_member_level_config_status_idx", columnList = "status")})
public class MemberLevelConfigDO implements Serializable {
    private static final long serialVersionUID = 2001085771908088934L;

    /**
     * 等级id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="member_level_config_seq")
    @SequenceGenerator(sequenceName="ms_mc_member_level_config_seq", name="member_level_config_seq",allocationSize = 1)
    private Long id;

    /**
     * 上级会员Id
     */
    @Column
    private Long memberId;

    /**
     * 上级会员角色Id
     */
    @Column
    private Long roleId;

    /**
     * 下级会员角色Id
     */
    @Column
    private Long subRoleId;

    /**
     * 下级会员角色的等级类型，定义在 MemberLevelTypeEnum 中
     */
    private Integer levelType;

    /**
     * 等级
     */
    @Column
    private Integer level;

    /**
     * 等级标签
     */
    @Column(columnDefinition = "varchar(30)")
    private String levelTag;

    /**
     * 升级分值标签
     */
    @Column(columnDefinition = "varchar(30)")
    private String scoreTag;

    /**
     * 升级阈值
     */
    @Column
    private Integer point;

    /**
     * 状态
     */
    @Column
    private Integer status;

    /**
     * 备注说明
     */
    @Column(columnDefinition = "varchar(100)")
    private String remark;

//    /**
//     * 多对一单向关联升级规则配置
//     */
//    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
//    @JoinColumn(name = "base_level_config_id")
//    private BaseLevelConfigDO config;

    /**
     * 一对多单向关联会员权益权益
     */
    @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.DETACH}, fetch = FetchType.LAZY)
    @JoinColumn(name = "member_level_config_id", referencedColumnName = "id")
    private Set<MemberRightConfigDO> rights;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public Long getSubRoleId() {
        return subRoleId;
    }

    public void setSubRoleId(Long subRoleId) {
        this.subRoleId = subRoleId;
    }

    public Integer getLevelType() {
        return levelType;
    }

    public void setLevelType(Integer levelType) {
        this.levelType = levelType;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public String getLevelTag() {
        return levelTag;
    }

    public void setLevelTag(String levelTag) {
        this.levelTag = levelTag;
    }

    public String getScoreTag() {
        return scoreTag;
    }

    public void setScoreTag(String scoreTag) {
        this.scoreTag = scoreTag;
    }

    public Integer getPoint() {
        return point;
    }

    public void setPoint(Integer point) {
        this.point = point;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

//    public BaseLevelConfigDO getConfig() {
//        return config;
//    }
//
//    public void setConfig(BaseLevelConfigDO config) {
//        this.config = config;
//    }

    public Set<MemberRightConfigDO> getRights() {
        return rights;
    }

    public void setRights(Set<MemberRightConfigDO> rights) {
        this.rights = rights;
    }
}
